/**
 * @filename: MyGenerator.java 2019-10-16
 * @project v0.0.1  V1.0
 * Copyright(c) 2018 BianPeng Co. Ltd. 
 * All right reserved. 
 */
package com.flying.cattle.mdg;

import java.sql.SQLException;
import java.util.Date;

import com.gitee.flying.cattle.mdg.entity.BasisInfo;
import com.gitee.flying.cattle.mdg.util.EntityInfoUtil;
import com.gitee.flying.cattle.mdg.util.Generator;
import com.gitee.flying.cattle.mdg.util.MySqlToJavaUtil;
import jdk.nashorn.internal.parser.Scanner;

/**
 * Copyright: Copyright (c) 2019
 * <p>说明： 自动生成工具</P>
 * <p>源码地址：https://gitee.com/flying-cattle/mybatis-dsc-generator</P>
 */
public class MyGenerator {
		// 基础信息：项目名、作者、版本
		public static final String PROJECT = "jdy-parent";
		public static final String AUTHOR = "LiShaoZhuo";
		public static final String VERSION = "V1.0";
		// 数据库连接信息：连接URL、用户名、秘密、数据库名
//		public static final String URL = "jdbc:mysql://127.0.0.1:3306/jdy?useSSL=false";
     	public static final String URL = "jdbc:mysql://192.168.0.123:3306/hz_crm?useSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8";
		public static final String NAME = "root";
//		public static final String PASS = "Jindan.root";
		public static final String PASS = "root";
		public static final String DATABASE = "hz_crm";
		// 类信息：类名、对象名（一般是【类名】的首字母小些）、类说明、时间
		public static final String CLASSNAME = "company";
		public static final String TABLE = "h_employee_info"; //TODO 记得更改
		public static final String CLASSCOMMENT = "";
		public static final String TIME = "2021年4月9日";
		public static final String AGILE = new Date().getTime()+"";
		// 路径信息，分开路径方便聚合工程项目，微服务项目
//		public static final String ENTITY_URL = "com.buybit.power.entity";
//		public static final String DAO_URL = "com.buybit.power.mapper";
//		public static final String XML_URL = "com.buybit.power.mapper.xml";
//		public static final String SERVICE_URL = "com.buybit.power.service";
//		public static final String SERVICE_IMPL_URL = "com.buybit.power.service.impl";
//		public static final String CONTROLLER_URL = "com.buybit.power.web";
	public static final String ENTITY_URL = "com.crm.jdy.common.pojo";
	public static final String Mapper_URL = "com.crm.jdy.common.mapper";
	public static final String XML_URL = "com.crm.jdy.common.mapper";
	public static final String SERVICE_URL = "com.crm.jdy.service.hr";// TODO: 2020/4/5修改这里
	public static final String SERVICE_IMPL_URL = "com.crm.jdy.service.hr"; // TODO: 2020/4/5修改这里
	public static final String CONTROLLER_URL = "com.crm.jdy.controller.hr";// TODO: 2020/4/5修改这里
	//是否是Swagger配置
    public static final String IS_SWAGGER = "true";

	public static void main(String[] args) {
		BasisInfo bi = new BasisInfo(PROJECT, AUTHOR, VERSION, URL, NAME, PASS, DATABASE, TIME, AGILE, ENTITY_URL,
				Mapper_URL, XML_URL, SERVICE_URL, SERVICE_IMPL_URL, CONTROLLER_URL,IS_SWAGGER);
		bi.setTable(TABLE);
		bi.setEntityName(MySqlToJavaUtil.getClassName(TABLE));
		bi.setObjectName(MySqlToJavaUtil.changeToJavaFiled(TABLE));
		bi.setEntityComment(CLASSCOMMENT);
		try{
			bi = EntityInfoUtil.getInfo(bi);
			String url = "D:\\HZ-Workspace\\CRM\\jdy-parent\\"; // TODO: 2020/4/4 修改这里
			String fileUrl = url + "jdy-common\\src\\main\\java\\";// 生成文件存放位置
			String fileUrl1 = url + "jdy-mapper\\src\\main\\java\\";// 生成文件存放位置
			String fileUrl2 = url + "jdy-mapper\\src\\main\\java\\";// 生成文件存放位置
			String fileUrl3 = url + "jdy-api\\src\\main\\java\\";// 生成文件存放位置
			String fileUrl4 = url + "jdy-service\\src\\main\\java\\";// 生成文件存放位置
			String fileUrl5 = url + "jdy-admin\\src\\main\\java\\";// 生成文件存放位置
//			String fileUrl = "E:\\";// 生成文件存放位置
		//  开始生成文件
			String aa1 = Generator.createEntity(fileUrl, bi).toString();
			String aa2 = Generator.createMapper(fileUrl1, bi).toString();
			String aa3 = Generator.createDaoImpl(fileUrl2, bi).toString();
			String aa4 = Generator.createService(fileUrl3, bi).toString();
			String aa5 = Generator.createServiceImpl(fileUrl4, bi).toString();
			String aa6 = Generator.createController(fileUrl5, bi).toString();
//			String aa1 = Generator.createEntity(fileUrl, bi).toString();
//			String aa2 = Generator.createDao(fileUrl, bi).toString();
//			String aa3 = Generator.createDaoImpl(fileUrl, bi).toString();
//			String aa4 = Generator.createService(fileUrl, bi).toString();
//			String aa5 = Generator.createServiceImpl(fileUrl, bi).toString();
//			String aa6 = Generator.createController(fileUrl, bi).toString();
			// 是否创建swagger配置文件
//			String aa7 = Generator.createSwaggerConfig(fileUrl, bi).toString();
			System.out.println(aa1);
			System.out.println(aa2);
			System.out.println(aa3);
			System.out.println(aa4);
			System.out.println(aa5);
			System.out.println(aa6);
			//System.out.println(aa7);
		} catch(SQLException e){
			e.printStackTrace();
		}

	}



}
